package com.huanong.controller.impl;
/*
 *@Author:anran
 *@Date:2020/12/8
 *@Version 1.0
 */

import com.huanong.common.grace.result.GraceJSONResult;
import com.huanong.controller.TypesControllerApi;
import com.huanong.pojo.Types;
import com.huanong.service.TypesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TypesController implements TypesControllerApi {

    @Autowired
    private TypesService typesService;

    @Override
    public GraceJSONResult query() {
        return GraceJSONResult.ok(typesService.query());
    }

    @Override
    public GraceJSONResult queryById(Integer TsId) {
        return GraceJSONResult.ok(typesService.queryById(TsId));
    }

    @Override
    public GraceJSONResult add(Types types) {
        int flag=typesService.add(types);
        if (flag==1){
            return GraceJSONResult.ok("添加产品类型成功");
        }else {
            return GraceJSONResult.errorMsg("添加产品类型失败");
        }
    }

    @Override
    public GraceJSONResult delete(Integer TsId) {
        int flag=typesService.delete(TsId);
        if (flag!=0){
            return GraceJSONResult.ok("删除产品类型成功");
        }else {
            return GraceJSONResult.errorMsg("删除产品类型失败");
        }
    }

    @Override
    public GraceJSONResult update(Types types) {
        int flag=typesService.update(types);
        if (flag!=0){
            return GraceJSONResult.ok("更新产品类型成功");
        }else {
            return GraceJSONResult.errorMsg("更新产品类型失败");
        }
    }
}
